<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>享阅汇</title>
		<script type="text/javascript" src="../../js/jquery.rem.min.js"></script>
		<script type="text/javascript" src="../../js/mui.min.js"></script>
		<script src="../../js/swiper.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../../css/wapReset.css" />
		<link rel="stylesheet" href="../../css/swiper.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/Make.css" />
		

		<script type="text/javascript" charset="utf-8">

				mui.init({						
					 pullRefresh : {
				    container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
				    down : {
					      style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
					      color:'#fc3553', //可选，默认“#2BD009” 下拉刷新控件颜色
					      height:'50px',//可选,默认50px.下拉刷新控件的高度,
					      range:'100px', //可选 默认100px,控件可下拉拖拽的范围
					      offset:'50px', //可选 默认0px,下拉刷新控件的起始位置
					      auto: false,//可选,默认false.首次加载自动上拉刷新一次
					      callback :function() {
				      		 var self = this; 
				      	 	 loadDown(this);
				      		} 
					   },
				    up : {
				    	 style:'circle',
					      height:10,//可选.默认50.触发上拉加载拖动距离
					      auto:false,//可选,默认false.自动上拉加载一次
					      contentrefresh : "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
					      contentnomore:'暂无数据',//可选，请求完毕若没有更多数据时显示的提醒内容；
					       callback :function() {
				      		 var self = this; 
				      	 	 loadup(this);
				      		} 
					   }
				  }
				});
		

		</script>

	
	</head>

	<body>
		
		
	<div class="mui-backdrop">
		

		<div class="MAyingdao_txt">	
				<p>今日热文已为小主准备好了</p>
				<p>分享到朋友圈,坐等收钱</p>
				<p class="my_txt"></p>
				<p class="MAying_blca_txt"></p>
		</div>
		
		
		<div class="Make_YD">
			<img src="../../image/1.jpg"/>
		</div>
		
		<div class="MAyingdao">				
				<p>新手红包</p>
				<p>1.00<k>元</k></p>
				<p>红包已经存入账户</p>
				<p>分享文章赚钱更多现金奖励</p>
				<img src="../../image/kaiqizhuanq.png" class="KAIqiImg"/>
				<p class="MAying_blca"></p>
		</div>
	</div>
	
		<header class="mui-bar mui-bar-nav B_Title">
			<img src="../../image/TitleRed.jpg" />
			<h1 class="mui-title B_mui-title">
	    	阅读赚钱
	    	
	    	<span class="B_hint">
	    		今日阅读分享收入
	    		<span class="B_genxin">0</span>
	    		元
	    	</span>
	    </h1>
		</header>

		<div class="mui-content B_banner">
			<img src="../../image/banner.png" />
		</div>
		
	        <div class="FIX_Top"></div>
		    <div id="topNav" class="swiper-container">
				  <div class="swiper-wrapper" id="Table_A">
				    
				  </div>
			</div>

		<div id="refreshContainer" class="mui-scroll-wrapper B_mui-card" style="text-align: left; position: relative !important; padding-top: 10px !important;">
		  <div class="mui-scroll">
		    <!--数据列表-->
		  	<ul class="mui-table-view B_view" id="B_mui-table-view">
					

				 
		    </ul>
		
		</div>
		</div>

	</body>

</html>
<script>
	
mui.plusReady(function(){	
//引导页	
	var showList = plus.storage.getItem("MakeYd");
	if(showList) {
			$(".mui-backdrop").show()
			$(".MAyingdao_txt").show()
			
			$(".MAying_blca_txt").on("click", function() {
				$(".mui-backdrop").hide()
				
				var	Opener = plus.webview.currentWebview().opener()
		 			mui.fire(Opener,'newsId',{
    				id:"1"
  				});
			})
			 
			var	Opener = plus.webview.currentWebview().opener()
		 		mui.fire(Opener,'newsId',{
    			id:"0"
  			});
  			
			$(".my_txt").on("click", function() {
					mui.ajax('http://120.76.201.26:8088/news/randNews', {
					dataType: 'json', //服务器返回json格式数据
					type: 'GET', //HTTP请求类型
					crossDomain: 'Boolean',
					timeout: 10000, //超时时间设置为10秒；
					headers: {
						'Content-Type': 'application/json'
					},
					success: function(data) {
						var Newid = data.data[0].id
						var Task_id= data.data[0].task_id
						var Asrc = data.data[0].news_link
						var UuId = localStorage.uuid;
						
						 $(".mui-backdrop").hide()
						 var	Opener = plus.webview.currentWebview().opener()
		 					mui.fire(Opener,'newsId',{
    						id:"1"
  						});
					
						mui.openWindow({
								url: 'More.html',
								id: "More",
								extras: {
									Task_id: Task_id,
									Asrc: Asrc,
									Newid: Newid,
									UuId:UuId
								}
							});
							
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(type);
					}
				});
				
			})
			
			Ondown()
		}else{
						//没打开
			 plus.storage.setItem("MakeYd","打开过赚钱")
			  $(".MAyingdao").show()
			  $(".mui-backdrop").show()
			  
			 $(".MAying_blca").on("click", function() {
			  	$(".MAyingdao").hide()
			  	$(".Make_YD").show()
			  })
			  
			  
			  
			 $(".KAIqiImg").on("click", function() {
			 	
			 	mui.ajax('http://120.76.201.26:8088/news/randNews', {
					dataType: 'json', //服务器返回json格式数据
					type: 'GET', //HTTP请求类型
					crossDomain: 'Boolean',
					timeout: 10000, //超时时间设置为10秒；
					headers: {
						'Content-Type': 'application/json'
					},
					success: function(data) {
						var Newid = data.data[0].id
						var Task_id= data.data[0].task_id
						var Asrc = data.data[0].news_link
						var UuId = localStorage.uuid;
						 $(".Make_YD").show()
						 $(".MAyingdao").hide()
						
						mui.openWindow({
								url: 'More.html',
								id: "More",
								extras: {
									Task_id: Task_id,
									Asrc: Asrc,
									Newid: Newid,
									UuId:UuId,
									Table:1
								}
							});
							
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(type);
					}
				});
			 	
			 })
			  
		var	Opener = plus.webview.currentWebview().opener()
		 mui.fire(Opener,'newsId',{
    		id:"0"
  		});
			  Ondown()
		}
	
var numYD = 1
$(".Make_YD").click(function(){
	numYD++
	if(numYD==2){
		$(".Make_YD").find("img").attr("src","../../image/2.jpg")
	}else if (numYD==3) {
		$(".Make_YD").find("img").attr("src","../../image/3.jpg")
	}else{
		$(".mui-backdrop").hide()
		
    	var	Opener = plus.webview.currentWebview().opener()
		
		 mui.fire(Opener,'newsId',{
    		id:"1"
  		});
  		
		Ondown()
	}
})

})		




//var B_grnginTxt = parseFloat(localStorage.reward_rmb) + parseFloat($(".B_genxin").text())
//var B_grnginTxt = parseFloat(localStorage.reward_rmb) + parseFloat($(".B_genxin").text())
//
//$(".B_genxin").html(B_grnginTxt)
console.log(localStorage.today_share_rmb)
if(localStorage.today_share_rmb) {
	$(".B_genxin").html(localStorage.today_share_rmb)
} else {
	$(".B_genxin").html(0)
}

var timer = setInterval(function() {
	$(".B_genxin").html(localStorage.today_share_rmb)
}, 7000)

var Num = 1
var cid = 1


/*新闻分类*/
var htmlA = ""
mui.ajax('http://120.76.201.26:8088/news/cate', {
	dataType: 'json', //服务器返回json格式数据
	type: 'GET', //HTTP请求类型
	crossDomain: 'Boolean',
	timeout: 10000, //超时时间设置为10秒；
	headers: {
		'Content-Type': 'application/json'
	},
	success: function(data) {
		//服务器返回响应，根据响应结果，分析是否登录成功；
		for(var i = 0; i < data.data.length; i++) {
			htmlA += '<div class="swiper-slide" cid="' + data.data[i].id + '">' +
				'<span>' + data.data[i].name + '</span>' +
				'</div>'
		}
		$("#Table_A").append(htmlA)
		mySwiper()
		$("#topNav .swiper-slide").eq(0).addClass('active')

	},
	error: function(xhr, type, errorThrown) {
		//异常处理；
		console.log(type);
	}
});

/*分类点击*/
mui('#Table_A').on('tap', 'div', function(e) {
	var Cid = this.getAttribute('cid');
	cid = Cid
	var htmlLi = ""
	$("#B_mui-table-view").html("")
	mui.ajax('http://120.76.201.26:8088/news/xyh_news?p=1&cid=' + cid, {
		dataType: 'json', //服务器返回json格式数据
		type: 'GET', //HTTP请求类型
		crossDomain: 'Boolean',
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；

			for(var i = 0; i < data.data.lists.length; i++) {

				htmlLi += '<li class="mui-table-view-cell mui-media B-media"  Asrc="' + data.data.lists[i].news_link + '"  Img="' + data.data.lists[i].imgs_url + '"  Tiele="' + data.data.lists[i].news_title + '"  newid="' + data.data.lists[i].id + '"  Task_id="' + data.data.lists[i].task_id + '">' +
					'<a href="javascript:;">' +
					'<img class="mui-media-object mui-pull-right B_media_Img" src="' + data.data.lists[i].imgs_url + '">' +
					'<div class="mui-media-body B_media_body">' + data.data.lists[i].news_title +
					'</div>' +
					'<div class="mui-media-body B_media_body_Bom">' +
					'<span class="B_Bom_L B_color">' + data.data.lists[i].news_pub_time +
					'</span>' +
					'<span class="B_Bom_R B_color">' + "分享" +
					'<k>' + "+" + data.data.lists[i].single_reward_rmb + '</k>' + "元/阅读" +
					'</span>' +
					'</div>' +
					'</a>' +
					'</li>'
			}

			$("#B_mui-table-view").append(htmlLi)
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});

});

var loadup = function(pullRefresh) {
	// 加载更多的内容到列表中
	var htmlLi = ""

	mui.ajax('http://120.76.201.26:8088/news/xyh_news?p=' + (Num + 1) + '&cid=' + cid, {
		dataType: 'json', //服务器返回json格式数据
		type: 'GET', //HTTP请求类型
		crossDomain: 'Boolean',
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			for(var i = 0; i < data.data.lists.length; i++) {
				2
				htmlLi += '<li class="mui-table-view-cell mui-media B-media"  Asrc="' + data.data.lists[i].news_link + '"  Img="' + data.data.lists[i].imgs_url + '"  Tiele="' + data.data.lists[i].news_title + '"  newid="' + data.data.lists[i].id + '"  Task_id="' + data.data.lists[i].task_id + '">' +
					'<a href="javascript:;">' +
					'<img class="mui-media-object mui-pull-right B_media_Img" src="' + data.data.lists[i].imgs_url + '">' +
					'<div class="mui-media-body B_media_body">' + data.data.lists[i].news_title +
					'</div>' +
					'<div class="mui-media-body B_media_body_Bom">' +
					'<span class="B_Bom_L B_color">' + data.data.lists[i].news_pub_time +
					'</span>' +
					'<span class="B_Bom_R B_color">' + "分享" +
					'<k>' + "+" + data.data.lists[i].single_reward_rmb + '</k>' + "元/阅读" +
					'</span>' +
					'</div>' +
					'</a>' +
					'</li>'
			}
			if(Num == data.data.totalPages) {
				pullRefresh.endPullupToRefresh(true)
			} else {
				pullRefresh.endPullupToRefresh(false)
				Num++
				$("#B_mui-table-view").append(htmlLi)
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);

		}
	});

	/*	pullRefresh.endPullupToRefresh(true);*/

};

var loadDown = function(pullRefresh) {
	// 加载更多的内容到列表中
	var htmlLi = ""
	Num = 1
	$("#B_mui-table-view").html("")
	mui.ajax('http://120.76.201.26:8088/news/xyh_news?p=' + Num + '&cid=' + cid, {
		dataType: 'json', //服务器返回json格式数据
		type: 'GET', //HTTP请求类型
		crossDomain: 'Boolean',
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			for(var i = 0; i < data.data.lists.length; i++) {

				htmlLi += '<li class="mui-table-view-cell mui-media B-media"  Asrc="' + data.data.lists[i].news_link + '" Img="' + data.data.lists[i].imgs_url + '"  Tiele="' + data.data.lists[i].news_title + '"  newid="' + data.data.lists[i].id + '"  Task_id="' + data.data.lists[i].task_id + '">' +
					'<a href="javascript:;">' +
					'<img class="mui-media-object mui-pull-right B_media_Img" src="' + data.data.lists[i].imgs_url + '">' +
					'<div class="mui-media-body B_media_body">' + data.data.lists[i].news_title +
					'</div>' +
					'<div class="mui-media-body B_media_body_Bom">' +
					'<span class="B_Bom_L B_color">' + data.data.lists[i].news_pub_time +
					'</span>' +
					'<span class="B_Bom_R B_color">' + "分享" +
					'<k>' + "+" + data.data.lists[i].single_reward_rmb + '</k>' + "元/阅读" +
					'</span>' +
					'</div>' +
					'</a>' +
					'</li>'
			}
			mui('#refreshContainer').pullRefresh().endPulldown()
			$("#B_mui-table-view").append(htmlLi)
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			mui('#refreshContainer').pullRefresh().endPulldown()
		}
	});
};

/*页面初始化*/
var detailPage = null;
//添加列表项的点击事件
mui('#B_mui-table-view').on('tap', 'li', function(e) {

	var UuId = localStorage.uuid;
	var Task_id = this.getAttribute('Task_id')
	var Tiele = this.getAttribute('Tiele')
	var Img = this.getAttribute('Img')
	var Asrc = this.getAttribute('Asrc')
	var newid = this.getAttribute('newid')
	var Newid = this.getAttribute('newid')
	localStorage.next_time = 0;

	mui.openWindow({
		url: 'More.html',
		id: "More",
		extras: {
			Task_id: Task_id,
			Tiele: Tiele,
			Img: Img,
			Asrc: Asrc,
			Newid: Newid,
			UuId: UuId
		}
	});

});

//导航
function mySwiper() {

	var mySwiper = new Swiper('#topNav', {
		freeMode: true,
		freeModeMomentumRatio: 0.5,
		slidesPerView: 'auto',
	});

	swiperWidth = mySwiper.container[0].clientWidth
	maxTranslate = mySwiper.maxTranslate();
	maxWidth = -maxTranslate + swiperWidth / 2

	$(".swiper-container").on('touchstart', function(e) {
		e.preventDefault()
	})

	mySwiper.on('tap', function(swiper, e) {

		/*   if (e.cancelable) {
		        // 判断默认行为是否已经被禁用
		        if (!e.defaultPrevented) {
		            e.preventDefault();
		        }
		    }*/

		slide = swiper.slides[swiper.clickedIndex]
		slideLeft = slide.offsetLeft
		slideWidth = slide.clientWidth
		slideCenter = slideLeft + slideWidth / 2
		// 被点击slide的中心点

		mySwiper.setWrapperTransition(300)

		if(slideCenter < swiperWidth / 2) {

			mySwiper.setWrapperTranslate(0)

		} else if(slideCenter > maxWidth) {

			mySwiper.setWrapperTranslate(maxTranslate)

		} else {
			nowTlanslate = slideCenter - swiperWidth / 2
			mySwiper.setWrapperTranslate(-nowTlanslate)
		}
		$("#topNav .active").removeClass('active')
		$("#topNav .swiper-slide").eq(swiper.clickedIndex).addClass('active')
	})
}





/*加载*/
function Ondown(){
	
var htmlLi = ""
	Num = 1
	$("#B_mui-table-view").html("")
	mui.ajax('http://120.76.201.26:8088/news/xyh_news?p=' + Num + '&cid=' + cid, {
		dataType: 'json', //服务器返回json格式数据
		type: 'GET', //HTTP请求类型
		crossDomain: 'Boolean',
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			for(var i = 0; i < data.data.lists.length; i++) {

				htmlLi += '<li class="mui-table-view-cell mui-media B-media"  Asrc="' + data.data.lists[i].news_link + '" Img="' + data.data.lists[i].imgs_url + '"  Tiele="' + data.data.lists[i].news_title + '"  newid="' + data.data.lists[i].id + '"  Task_id="' + data.data.lists[i].task_id + '">' +
					'<a href="javascript:;">' +
					'<img class="mui-media-object mui-pull-right B_media_Img" src="' + data.data.lists[i].imgs_url + '">' +
					'<div class="mui-media-body B_media_body">' + data.data.lists[i].news_title +
					'</div>' +
					'<div class="mui-media-body B_media_body_Bom">' +
					'<span class="B_Bom_L B_color">' + data.data.lists[i].news_pub_time +
					'</span>' +
					'<span class="B_Bom_R B_color">' + "分享" +
					'<k>' + "+" + data.data.lists[i].single_reward_rmb + '</k>' + "元/阅读" +
					'</span>' +
					'</div>' +
					'</a>' +
					'</li>'
			}
			$("#B_mui-table-view").append(htmlLi)
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
		}
	});
}
</script>
